'use strict';

/* Filters */

angular.module('merydeFilters', []).filter('filterByCategory', function() {
	return function(merydes, filter) {
		var result = [];
		var meryde, i;
		for (i = 0; i < merydes.length; i++) {
			meryde = merydes[i];
			if (!filter || filter[meryde.bonusType] || noFilter(filter))
				result.push(meryde);
		}
		;
		return (result);
	};
});

function noFilter(filterObj) {
	for ( var key in filterObj) {
		if (filterObj[key]) {
			// There is at least one checkbox checked
			return false;
		}
	}

	// No checkbox was found to be checked
	return true;
}